
class people:
    name = ""
    age = 0

    #私有属性
    _weight = 0

    def __init__(self,name,age,weight):
        self.name = name
        self.age = age
        self._weight = weight

    def speak(self):
        print("%s 说：我 %d 岁。" %(self.name,self.age))

#单继承
class student(people):
    grade = ""

    def __init__(self,name,age,weight,grade):
        #super().__init__(name,age,weight)
        people.__init__(self,name,age,weight)
        self.grade = grade

    def speak(self):
        print("%s 说: 我 %d 岁了，我在读 %s 年级" %(self.name,self.age,self.grade))

class speaker():
    topic = ""
    name = ""

    def __init__(self,name,topic):
        self.name = name
        self.topic = topic

    def speak(self):
        print("我叫 %s，我是一个演说家，我演讲的主题是 %s" % (self.name, self.topic))

#多继承
    """
    多继承：
        查找第一个父类
        需要注意圆括号中父类的顺序，若，是父类中有相同的方法名而在子类使用时未指定，Python 从左至右搜索 即方法在子类中未找到时，从左到右查找父类中是否包含方法。
    """
class sample(speaker,student):
    a = ""

    def __init__(self,name,age,weight,grade,topic):
        #super().__init__(name,age,weight,grade)
        #super().__init__(name,topic)
        student.__init__(self,name,age,weight,grade)
        speaker.__init__(self,name,topic)

class main:
    #p = people("Watermelon",18,15)
    #p.speak()

    #s = student("Watermelon",18,15,"大一")
    #s.speak()

    s = sample("Watermelon",18,15,"大一","Python")
    s.speak()